package com.green.common.fusionchart;

import java.util.ArrayList;
import java.util.List;

import com.green.common.fusionchart.enums.DefaultColorEnum;


public class StackedColumn2D extends Column2D {
	
	public void setDataSets(List<DataSet> dataSets,
			List<DefaultColorEnum> colors) {
		setColorForSet(dataSets, colors);
		super.setDataSets(dataSets);
	}
	
	public void setDataSets(List<DataSet> dataSets){
		setColorForSet(dataSets, null);
		super.setDataSets(dataSets);
	}

	public void setColorForSet(List<DataSet> sets, List<DefaultColorEnum> colors) {
		if (colors == null || colors.size() == 0) {
			colors = new ArrayList<DefaultColorEnum>();
			for (DefaultColorEnum color : DefaultColorEnum.values()) {
					colors.add(color);
			}
		}
		int i = 0;
		for (DataSet set : sets) {
			if(i == 1){
				set.setColor(colors.get(5).getColor());
			}else if(i == 5){
				set.setColor(colors.get(1).getColor());
			}else{
				set.setColor(colors.get(i).getColor());
			}
			i++;
			if (i == colors.size())
				i = 0;
		}
	}
	
}
